let app = getApp()
var stylecss = require('../utils/stylecss.js');
Component({
    properties: {
      },
      data:{
        visible:false
      },
    lifetimes: {
        attached: function () {
            var that=this
            wx.request({
              url: app.globalData.siteroot,
              data: {
                do:'AdvertPopup_getAdvertPopup',
              },
              success: function(res) {
                  that.setData({
                    advertInfo:res.data.data,
                    popup_type:res.data.data.popup_type,
                    popup_time:res.data.data.popup_time
                  })
                  if(res.data.code==200)
                  {
                    that.setData({
                        maskShow:true,
                        visible:true
                      }) 
                  }
              }
            })
         }
      },
    methods: {
      golook:function(){
        var that=this
            if(this.data.popup_type==2){
              var popup_time=this.data.popup_time*60000
              setTimeout(function() {
                that.setData({
                  maskShow:true,
                  visible:true
                 })
              }
              ,popup_time)
            }  
        this.setData({
          maskShow:false,
          visible:false
        })
          var advert_url=JSON.parse(JSON.parse(this.data.advertInfo.advert_url))
          stylecss.jumpurl(advert_url);
        },
        closemask:function(){
            var that=this
            if(this.data.popup_type==2){
              var popup_time=this.data.popup_time*60000
              setTimeout(function() {
                that.setData({
                  maskShow:true,
                  visible:true
                 })
              }
              ,popup_time)
            }  
            this.setData({
                maskShow:false,
                visible:false
              })
        }
    }
});
